using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using MTRC.ODMS.DAL.SOM.CodeSetup;

namespace MTRC.ODMS.Web.SOM.FireProtection
{

    /// <summary>
    /// Author :NingHeming
    /// Get Fire Zone Group Loop Status
    /// </summary>
    public partial class FireZoneGroupLoopStatus : BasePage_SOM
    {
        #region MenuID

        protected override string MenuID
        {
            get
            {
                return "M140303";
            }
        }
        #endregion
        #region Page Init And Load
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.ChangeLanguage += new ChangeLanguageEventHandler(ChangeLanguage_Function);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //delete by gordon 2015/06/11
                //BindDefaultDDL(); 
                //GetFireLinkStatus();
                //SetLanguage();
                //---------------------------

                //Add By Gordon 20150625
                SetLanguage();
            }
            //Add By Gordon 2015/06/11
            BindRptFZGrpList();
            //Response.AddHeader("refresh", DAL.CommonData.GetNumVal("SOM_RefreshTime").ToString());
            this.tmrAutoRefresh.Interval =int.Parse ( DAL.CommonData.GetNumVal("SOM_RefreshTime").ToString ());
            //SetTable(); //delete By Gordon 2015/06/11
            this.lblStatusReportTimeInfo.Text = this.FormatDateTime (DAL.COM.Util.GetCurrentSystemTime(),true,true);
           
        }

        protected void tmrAutoRefresh_Tick(object sender, EventArgs e)
        {
            BindRptFZGrpList();
            this.lblStatusReportTimeInfo.Text = this.FormatDateTime(DAL.COM.Util.GetCurrentSystemTime(), true, true);
        }

        
        
        #endregion

        #region SetLanguage

        void ChangeLanguage_Function(object sender, EventArgs e)
        {
            //Update By Gordon 2015/06/11
            SetLanguage();
            BindRptFZGrpList();
            //---------------------------
        }
        
        
        

        #endregion

        #region Add By Gordon 2015/06/25

        /// <summary>
        /// BindRptFZGrpList
        /// </summary>
        protected void BindRptFZGrpList()
        {
            //update  by gordon 20151021 U247
            //DataTable dtCurrentFireLink = MTRC.ODMS.DAL.SOM.CodeSetup.CDFireLink.GetFirelinkCode(this.LangCode, this.CurrentStation);
            DataTable dtCurrentFireLink = MTRC.ODMS.DAL.SOM.CodeSetup.CDFireLink.GetFirelinkCode(this.LangCode, this.CurrentLocation);
            BindRepeater(rptFZGrpList, dtCurrentFireLink);
        }

        /// <summary>
        /// rptFZGrpList_ItemDataBound
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rptFZGrpList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //Get FireLink Id
            HiddenField hdnFireLinkId = e.Item.FindControl("hdnFireLinkId") as HiddenField;
            //Get FireZoneGroup Container

            PlaceHolder phTable = e.Item.FindControl("phTable") as PlaceHolder;
            //Bind FireZoneGroup Table
            SetTable(phTable, hdnFireLinkId.Value);

            //Bind FireLink Status
            Label lblFireLink = e.Item.FindControl("lblFireLink") as Label;
            //add by gordon 20150723 U128
            Label lblContainerFireLink = e.Item.FindControl("lblContainerFireLink") as Label;
            BindFireLinkStatus(lblFireLink, lblContainerFireLink,hdnFireLinkId.Value);
        }

        /// <summary>
        /// SetLanguage
        /// </summary>
        private void SetLanguage()
        {
            lblFireLinkStatus.Text = GetLabel("SOM_FireLinkStatus", true);//BJL4 or HK

            this.lblFireProtectionGroup.Text = this.GetLabel("SOM_FireGroupStatus");
            this.lblStatusReportTime.Text = this.GetLabel("SOM_FrieStatusReportTime", true);
            lblIsolateFireZone.Text = this.GetLabel("SOM_FireGroupStatus", true);
            this.btnRefresh.Text = this.GetLabel("COM_Refresh");
            DataTable dtZoneStatus = DAL.SOM.CodeSetup.CDFireGroupStatus.GetFireZoneGroupStatusBylangCode(this.LangCode);
            if (dtZoneStatus.Rows.Count > 0)
            {
                lblNormal.Text = dtZoneStatus.Rows[0]["Normal"].ToString();
                lblIsolate.Text = dtZoneStatus.Rows[0]["Isolated"].ToString();
                lblRestore.Text = dtZoneStatus.Rows[0]["Restored"].ToString();

                //Ref To Req12.2
                if (DAL.CommonData.GetCharVal("SOM_FireZoneGroupStatus_HideRestore").ToUpper() == "Y")
                {
                    lblRestore.Visible = false;
                    lblZGComma.Visible = false;
                }
                
            }

            DataTable dtFireLinkStatus = DAL.SOM.CodeSetup.CDFireLinkStatus.GetAllFireLinkStatus(this.LangCode);
            if (dtFireLinkStatus.Rows.Count > 0)
            {
                lblFLNormal.Text = dtFireLinkStatus.Rows[0]["FireLinkStatusCode"].ToString();
                lblOOS.Text = dtFireLinkStatus.Rows[1]["FireLinkStatusCode"].ToString();
                lblVRT.Text = dtFireLinkStatus.Rows[2]["FireLinkStatusCode"].ToString();
                lblTest.Text = dtFireLinkStatus.Rows[3]["FireLinkStatusCode"].ToString();

                //add by gordon 20150722
                lblFLNormal.Style.Add("color", dtFireLinkStatus.Rows[0]["FireLinkStatusFontColor"].ToString());
                //lblContainerNormal.Style.Add("background-color", dtFireLinkStatus.Rows[0]["FireLinkStatusBGColor"].ToString());//delete by gordon 20150826 U175

                //lblOOS.Style.Add("color", dtFireLinkStatus.Rows[1]["FireLinkStatusFontColor"].ToString());
                lblOOS.Style.Add("color", dtFireLinkStatus.Rows[1]["FireLinkStatusBGColor"].ToString());//update by gordon 20150826 U175
                //lblContainerOOS.Style.Add("background-color", dtFireLinkStatus.Rows[1]["FireLinkStatusBGColor"].ToString());//delete by gordon 20150826 U175

                //lblVRT.Style.Add("color", dtFireLinkStatus.Rows[2]["FireLinkStatusFontColor"].ToString());
                lblVRT.Style.Add("color", dtFireLinkStatus.Rows[2]["FireLinkStatusBGColor"].ToString());//update by gordon 20150826 U175
                //lblContainerVRT.Style.Add("background-color", dtFireLinkStatus.Rows[2]["FireLinkStatusBGColor"].ToString());//delete by gordon 20150826 U175

                //lblTest.Style.Add("color", dtFireLinkStatus.Rows[3]["FireLinkStatusFontColor"].ToString());
                lblTest.Style.Add("color", dtFireLinkStatus.Rows[3]["FireLinkStatusBGColor"].ToString());//update by gordon 20150826 U175
                //lblContainerTest.Style.Add("background-color", dtFireLinkStatus.Rows[3]["FireLinkStatusBGColor"].ToString());//delete by gordon 20150826 U175
                //------------------------

                if (DAL.CommonData.GetCharVal("MV_SOM_FireZoneGroupLoopStatusVRT_Visible").ToUpper() == "N")
                {
                    lblVRT.Visible = false;
                    lblComma.Visible = false;
                }
            }
        }

        /// <summary>
        /// BindFireLinkStatus
        /// </summary>
        /// <param name="lblFireLink">lblFireLink</param>
        /// <param name="fireLinkId">fireLinkId</param>
        private void BindFireLinkStatus(Label lblFireLink,Label lblContainerFireLink, string fireLinkId)
        {
            DataTable dt = DAL.SOM.CodeSetup.CDFireLinkStatus.GetFireStatusByID(int.Parse(fireLinkId));
            //add by gordon 20150722 U128
            string colorString = "black";
            string bgColorString = "lightgrey";
            if (dt.Rows.Count > 0)
            {
                //update by gordon 20150722 U128
                //string colorString = "black";
                //string bgColorString = "lightgrey";
                //string statusId = dt.Rows[0]["FirelinkStatusID"].ToString();
                //switch (statusId)
                //{
                //    case "1": colorString = "black"; break;
                //    case "2": colorString = "Red"; break;
                //    case "3": colorString = "Fuchsia"; break;
                //    case "4": colorString = "#FFCC33"; break;
                //}
                //update by gordon 20150826 U175-----
                //colorString = dt.Rows[0]["FirelinkStatusFontColor"].ToString();
                colorString = dt.Rows[0]["FirelinkStatusID"].ToString() == "1" ? dt.Rows[0]["FirelinkStatusFontColor"].ToString() : dt.Rows[0]["FirelinkStatusBGColor"].ToString();
                //bgColorString = dt.Rows[0]["FirelinkStatusBGColor"].ToString();
                //-----------------------------------
                //-------------------------------

                //lblFireLink.Style.Add("color", colorString);
            }
            //add by gordon 20150722 U128
            lblFireLink.Style.Add("color", colorString);
            //lblContainerFireLink.Style.Add("background-color", bgColorString);//delete by gordon 20150826 U175
        }

        /// <summary>
        /// Create Table To Display the Fire Zone Group Status
        /// </summary>
        /// <returns></returns>
        private string CreateTable(string fireLinkIdStr)
        {
            //StringBuilder sHtml = new StringBuilder();
            //sHtml.Append ("<table>");

            //--added by huangyao 20090108
            int fireLinkCode = 0;
            int.TryParse(fireLinkIdStr, out fireLinkCode);

            DataTable dt = MTRC.ODMS.DAL.SOM.CodeSetup.CDFireGroupStatus.GetFireZoneGroupStatus(fireLinkCode);
            //---------------end--

            StringBuilder tableString = new StringBuilder();
            if (dt.Rows.Count > 0)
            {
                int MaxRows = Convert.ToInt16(dt.Rows[0]["MaxRowNo"]);
                int MaxSeqs = Convert.ToInt16(dt.Rows[0]["MaxSeqNo"]);
                tableString.Append("<table cellspacing='0'>");
                for (int i = 1; i < MaxRows + 1; i++)
                {
                    tableString.Append("<tr>");

                    for (int j = 1; j < MaxSeqs + 1; j++)
                    {
                        DataRow[] rows = dt.Select("RowNo=" + i + " and SeqNo=" + j, "SeqNo,RowNo ASC");
                        if (rows.Length > 0)
                        {
                            tableString.Append("<td class='TdFireLink'>");
                            //tableString.Append("<span>");
                            string style = "style='Normal;font-weight:Normal;'";
                            if (Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) == 1)
                            {
                                style = "style='color:black;font-weight:Normal;'";
                            }
                            else if (Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) == 2)
                            {
                                style = "style='color:red;font-weight:Normal;'";
                            }
                            else if (Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) == 3)
                            {
                                //Ref To Req12.2
                                if (DAL.CommonData.GetCharVal("SOM_FireZoneGroupStatus_HideRestore").ToUpper() == "N")
                                {
                                    style = "style='color:green;font-weight:Normal'";
                                }
                                else 
                                {
                                    style = "style='color:black;font-weight:Normal'";
                                }                            
                            }
                            else
                            {
                                style = "style='color:black;font-weight:Normal;'";
                            }
                            tableString.Append("<div id='lbl" + rows[0]["FireZoneGrpID"] + "'");
                            //tableString.Append(style);
                            int nFireZoneGrpCode = Convert.ToInt32(rows[0]["FireZoneGrpCode"].ToString().Length);
                            //Issue U36: Update By Gordon 2015/05/28
                            //tableString.Append("style='width:142px';float:left;'>");
                            tableString.Append("style='width:61px; float:left;'>");
                            //--------------------------------------
                            tableString.Append("<a ");
                            tableString.Append(style);
                            if (rows[0]["DetailLocation"].ToString() != string.Empty)
                            {
                                tableString.Append(" title=\"" + rows[0]["DetailLocation"].ToString() + "\"");
                            }
                            string strTemp = "";
                            //if (DAL.Security.User.CanFunctionItemAccess("M140303_F1", this.ODMUser.UserProfileID, this.MenuID))
                            if (Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) == 2)
                            {
                                //--added by huangyao 20090108
                                //strTemp = " href='FireProtectionEnquiry.aspx?FireZoneGrpID=" + Convert.ToInt32(rows[0]["FireZoneGrpID"].ToString()) + "&FireLinkID=" + Convert.ToInt32(ddlFireLinkCode.SelectedValue.ToString()) + "'>" + rows[0]["FireZoneGrpCode"].ToString() + "[X]" + "</a>";
                                //fireLinkCode
                                strTemp = " href='FireProtectionEnquiry.aspx?FireZoneGrpID=" + Convert.ToInt32(rows[0]["FireZoneGrpID"].ToString()) + "&FireLinkID=" + fireLinkCode.ToString() + "'>" + rows[0]["FireZoneGrpCode"].ToString() + "[X]" + "</a>";
                                //---end
                            }
                            else
                            {
                                strTemp = " href='FireZoneGroupLoopStatus.aspxFireZoneGrpIDStatusID=" + Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) + "' style='cursor:default' onclick='return false;'>" + rows[0]["FireZoneGrpCode"].ToString() + "[]" + "</a>";
                            }
                            //strTemp = " href='FireProtectionEnquiry.aspx?FireZoneGrpIDStatusID=" + Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) + "'>" +rows[0]["FireZoneGrpCode"].ToString() + "</a>";
                            tableString.Append(strTemp);
                            //tableString.Append("");
                            tableString.Append("</div>");
                            //rows[0]["FireZoneGrpIDStatusID"].ToString();
                            tableString.Append("</td>");
                        }
                        else
                        {
                            tableString.Append("<td class='TdFireLink'>&nbsp;</td>");
                        }
                    }

                    tableString.Append("</tr>");
                }
                tableString.Append("</table>");
            }

            return tableString.ToString();
        }
        private void SetTable(PlaceHolder phTable, string fireLinkId)
        {
            HtmlGenericControl control = new HtmlGenericControl();
            string tbHTML = this.CreateTable(fireLinkId);
            if (string.IsNullOrEmpty(tbHTML))
                tbHTML = "&nbsp;";
            control.InnerHtml = tbHTML;
            
            phTable.Controls.Add(control);
        }

        #endregion

        #region Delete By Gordon 2015/06/11
        /// <summary>
        /// Bind the FireLinkCode
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void ddlFireLinkCode_SelectedIndexChanged(object sender, EventArgs e)
        //{
            //Delte By Gordon 2015/06/11
            //Session[BLL.COM.Session.SOM_FireLinkCode] = null;
            ////Session["FireLinkStatus"] = null;

            ////--added by huangyao 20090108
            //int FireLinkCode = 0;
            ////Session["FireLinkStatus"] = null;
            //int.TryParse(ddlFireLinkCode.SelectedValue.ToString(), out FireLinkCode);
            ////-----end--
            //Session[BLL.COM.Session.SOM_FireLinkCode] = FireLinkCode;
            //DataTable dt = DAL.SOM.CodeSetup.CDFireLinkStatus.GetFireStatusByID(FireLinkCode);

            ////begin updata, by hzx, on 20090113
            ////BindListControl(this.rblFireLinkStatus, "FirelinkStatusID", "FireLinkStatus", ODMS.DAL.SOM.CodeSetup.CDFireLinkStatus.GetFireLinkStatus(this.LangCode, this.Version.ToString()), false); --updata bu hzx,on 20090113
            //BindListControl(this.rblFireLinkStatus, "FireLinkStatusID", "FireLinkStatusCode", DAL.SOM.CodeSetup.CDFireLinkStatus.GetAllFireLinkStatus(this.LangCode), false);

            ////if (this.Version == MTRC.ODMS.BLL.EnvVersion.BJL4 && rblFireLinkStatus.Items.FindByValue("3") != null) //del by zengshunbo 2009-06-15
            //if (DAL.CommonData.GetCharVal("MV_SOM_FireZoneGroupLoopStatusVRT_Visible").ToUpper() == "N" && rblFireLinkStatus.Items.FindByValue("3") != null)
            //{
            //    rblFireLinkStatus.Items.Remove(rblFireLinkStatus.Items.FindByValue("3"));
            //}
            //this.rblFireLinkStatus.SelectedIndex = 0;
            ////end updata

            ////Session["FireLinkStatus"] = dt.Rows[0]["FirelinkStatusID"];
            //if (dt.Rows.Count > 0)
            //{
            //    //---huangyao 20090107: fixed issue leave behind by NHM 
            //    //if (rblFireLinkStatus.Items.FindByValue(FireLinkCode.ToString()) != null)
            //    //{
            //    //    this.FindByValueAndSelect(rblFireLinkStatus, dt.Rows[0]["FirelinkStatusID"].ToString());

            //    //    //this.rblFireLinkStatus.Items.FindByValue(dt.Rows[0]["FirelinkStatusID"].ToString()).Selected = true;
            //    //}

            //    this.FindByValueAndSelect(rblFireLinkStatus, dt.Rows[0]["FirelinkStatusID"].ToString());
            //    //--end --huangyao 20090107: fixed issue leave behind by NHM 
            //}

       //}
        /// <summary>
        /// Bind Data to Controls
        /// </summary>
        //private void BindDefaultDDL()
        //{
        //    Delete By Gordon 2015/06/11
        //    //----huangyao 20090107: action log 0852 point 2
        //    //BindListControl(this.ddlFireLinkCode, "FirelinkID", "FireLinkCode", ODMS.DAL.SOM.CodeSetup.CDFireLink .GetFirelinkCode (this.LangCode ,0),false);
        //    //DataTable dtCurrentFireLink = MTRC.ODMS.DAL.SOM.CodeSetup.CDFireLink.GetFirelinkCode(this.LangCode ,this.CurrentStation);
        //    //if (dtCurrentFireLink.Rows.Count > 0)
        //    //{
        //    //    if (dtCurrentFireLink.Rows[0]["FireLinkID"] != null) 
        //    //    {
        //    //        this.FindByValueAndSelect(ddlFireLinkCode, dtCurrentFireLink.Rows[0]["FireLinkID"].ToString());
        //    //        //this.ddlFireLinkCode.Items.FindByValue(dtCurrentFireLink.Rows[0]["FireLinkID"].ToString());
        //    //    }
        //    //}

        //    DataTable dtCurrentFireLink = MTRC.ODMS.DAL.SOM.CodeSetup.CDFireLink.GetFirelinkCode(this.LangCode, this.CurrentStation);
        //    BindListControl(this.ddlFireLinkCode, "FirelinkID", "FireLinkCode", dtCurrentFireLink, false);
        //    if (dtCurrentFireLink.Rows.Count > 0)
        //    {
        //        //avoid select void record
        //        if(dtCurrentFireLink.Select("FlagObsolete=false").Length > 0)
        //        {
        //            DataRow tempRow = dtCurrentFireLink.Select("FlagObsolete=false")[0];
        //            this.FindByValueAndSelect(ddlFireLinkCode, tempRow["FireLinkID"].ToString());
        //        }
        //    }
        //    ////--end--huangyao 20090107: action log 0852 point 2

        //    this.rblFireLinkStatus.SelectedIndex = -1;

        //    //begin updata, by hzx, on 20090113
        //    //BindListControl(this.rblFireLinkStatus, "FirelinkStatusID", "FireLinkStatus", ODMS.DAL.SOM.CodeSetup.CDFireLinkStatus.GetFireLinkStatus(this.LangCode, this.Version.ToString()), false); --updata bu hzx,on 20090113
        //    BindListControl(this.rblFireLinkStatus, "FireLinkStatusID", "FireLinkStatusCode", DAL.SOM.CodeSetup.CDFireLinkStatus.GetAllFireLinkStatus(this.LangCode), false);
        //    if (DAL.CommonData.GetCharVal("MV_SOM_FireZoneGroupLoopStatusVRT_Visible").ToUpper() == "N" && rblFireLinkStatus.Items.FindByValue("3") != null)
        //    {
        //        rblFireLinkStatus.Items.Remove(rblFireLinkStatus.Items.FindByValue("3"));
        //    }
        //    this.rblFireLinkStatus.SelectedIndex = 0;
        //    //end updata

        //    if (Session[BLL.COM.Session.SOM_FireLinkCode] != null)
        //    {
        //        this.FindByValueAndSelect(ddlFireLinkCode, Session[BLL.COM.Session.SOM_FireLinkCode].ToString());
        //        //this.ddlFireLinkCode.Items.FindByValue(Session[BLL.COM.Session.SOM_FireLinkCode].ToString()).Selected = true;
        //    }
        //    if (Session[BLL.COM.Session.SOM_FireLinkCode] != null)
        //    {

        //        DataTable dt = DAL.SOM.CodeSetup.CDFireLinkStatus.GetFireStatusByID(int.Parse(Session[BLL.COM.Session.SOM_FireLinkCode].ToString()));

        //        //begin updata, by hzx, on 20090113
        //        //BindListControl(this.rblFireLinkStatus, "FirelinkStatusID", "FireLinkStatus", ODMS.DAL.SOM.CodeSetup.CDFireLinkStatus.GetFireLinkStatus(this.LangCode, this.Version.ToString()), false); --updata bu hzx,on 20090113
        //        BindListControl(this.rblFireLinkStatus, "FireLinkStatusID", "FireLinkStatusCode", DAL.SOM.CodeSetup.CDFireLinkStatus.GetAllFireLinkStatus(this.LangCode), false);
        //        if (DAL.CommonData.GetCharVal("MV_SOM_FireZoneGroupLoopStatusVRT_Visible").ToUpper() == "N" && rblFireLinkStatus.Items.FindByValue("3") != null)
        //        {
        //            rblFireLinkStatus.Items.Remove(rblFireLinkStatus.Items.FindByValue("3"));
        //        }
        //        this.rblFireLinkStatus.SelectedIndex = 0;
        //        //end updata

        //        if (dt.Rows.Count > 0)
        //        {
        //            //---huangyao 20090107: fixed issue leave behind by NHM 
        //            //if (dt.Rows[0]["FirelinkStatusID"] != DBNull.Value) //this field not null in DB
        //            //{
        //            //    this.FindByValueAndSelect(rblFireLinkStatus, dt.Rows[0]["FirelinkStatusID"].ToString());
        //            //    //this.rblFireLinkStatus.Items.FindByValue(dt.Rows[0]["FirelinkStatusID"].ToString()).Selected = true;
        //            //}
        //            this.FindByValueAndSelect(rblFireLinkStatus, dt.Rows[0]["FirelinkStatusID"].ToString());
        //            //--end --huangyao 20090107: fixed issue leave behind by NHM 
        //        }
        //        //this.FindByValueAndSelect(rblFireLinkStatus, dt.Rows[0]["FirelinkStatusID"].ToString());
        //        //this.rblFireLinkStatus.Items.FindByValue(dt.Rows[0]["FirelinkStatusID"].ToString()).Selected = true;
        //    }
        //    //if (!DAL.Security.User.CanFunctionItemAccess("M140303_F1", this.ODMUser.UserProfileID, this.MenuID))
        //    //{
        //    //    this.ddlFireLinkCode.Enabled = false;
        //    //}
        //}
        //Delete By Gordon 2015/06/11
        ///// <summary>
        ///// Create Table To Display the Fire Zone Group Status
        ///// </summary>
        ///// <returns></returns>
        //private string  CreateTable()
        //{ 
        //    //StringBuilder sHtml = new StringBuilder();
        //    //sHtml.Append ("<table>");

        //    //--added by huangyao 20090108
        //    int fireLinkCode = 0;
        //    int.TryParse(ddlFireLinkCode.SelectedValue.ToString(), out fireLinkCode);

        //        DataTable dt = MTRC.ODMS.DAL.SOM.CodeSetup.CDFireGroupStatus.GetFireZoneGroupStatus(fireLinkCode);
        //    //---------------end--

        //        StringBuilder tableString = new StringBuilder();
        //        if (dt.Rows.Count > 0)
        //        {
        //            int MaxRows = Convert.ToInt16(dt.Rows[0]["MaxRowNo"]);
        //            int MaxSeqs = Convert.ToInt16(dt.Rows[0]["MaxSeqNo"]);
        //            tableString.Append("<table>");
        //            for (int i = 1; i < MaxRows + 1; i++)
        //            {
        //                tableString.Append("<tr>");

        //                for (int j = 1; j < MaxSeqs + 1; j++)
        //                {
        //                    DataRow[] rows = dt.Select("RowNo=" + i + " and SeqNo=" + j, "SeqNo,RowNo ASC");
        //                    if (rows.Length > 0)
        //                    {
        //                        tableString.Append("<td class='TdFireLink'>");
        //                        //tableString.Append("<span>");
        //                        string style = "style='Normal;font-weight:Normal;'";
        //                        if (Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) == 1)
        //                        {
        //                            style = "style='color:black;font-weight:Normal;'";
        //                        }
        //                        else if (Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) == 2)
        //                        {
        //                            style = "style='color:red;font-weight:Normal;'";
        //                        }
        //                        else if (Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) == 3)
        //                        {
        //                            style = "style='color:green;font-weight:Normal'";
        //                        }
        //                        else
        //                        {
        //                            style = "style='color:black;font-weight:Normal;'";
        //                        }
        //                        tableString.Append("<div id='lbl" + rows[0]["FireZoneGrpID"] + "'");
        //                        //tableString.Append(style);
        //                        int nFireZoneGrpCode = Convert.ToInt32(rows[0]["FireZoneGrpCode"].ToString().Length);
        //                        //Issue U36: Update By Gordon 2015/05/28
        //                        //tableString.Append("style='width:142px';float:left;'>");
        //                        tableString.Append("style='float:left;'>");
        //                        //--------------------------------------
        //                        tableString.Append("<a ");
        //                        tableString.Append(style);
        //                        if (rows[0]["DetailLocation"].ToString () != string.Empty)
        //                        {
        //                            tableString.Append(" title=\"" + rows[0]["DetailLocation"].ToString()+"\"");
        //                        }
        //                        string strTemp = "";
        //                        //if (DAL.Security.User.CanFunctionItemAccess("M140303_F1", this.ODMUser.UserProfileID, this.MenuID))
        //                        if (Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) == 2)
        //                        {
        //                            //--added by huangyao 20090108
        //                            //strTemp = " href='FireProtectionEnquiry.aspx?FireZoneGrpID=" + Convert.ToInt32(rows[0]["FireZoneGrpID"].ToString()) + "&FireLinkID=" + Convert.ToInt32(ddlFireLinkCode.SelectedValue.ToString()) + "'>" + rows[0]["FireZoneGrpCode"].ToString() + "[X]" + "</a>";
        //                            //fireLinkCode
        //                            strTemp = " href='FireProtectionEnquiry.aspx?FireZoneGrpID=" + Convert.ToInt32(rows[0]["FireZoneGrpID"].ToString()) + "&FireLinkID=" + fireLinkCode.ToString() + "'>" + rows[0]["FireZoneGrpCode"].ToString() + "[X]" + "</a>";
        //                            //---end
        //                        }
        //                        else
        //                        {
        //                            strTemp = " href='FireZoneGroupLoopStatus.aspxFireZoneGrpIDStatusID=" + Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) + "' style='cursor:default' onclick='return false;'>" + rows[0]["FireZoneGrpCode"].ToString() + "[]" + "</a>";
        //                        }
        //                        //strTemp = " href='FireProtectionEnquiry.aspx?FireZoneGrpIDStatusID=" + Convert.ToInt32(rows[0]["FireZoneGrpIDStatusID"].ToString()) + "'>" +rows[0]["FireZoneGrpCode"].ToString() + "</a>";
        //                        tableString.Append(strTemp);
        //                        //tableString.Append("");
        //                        tableString.Append("</div>");
        //                        //rows[0]["FireZoneGrpIDStatusID"].ToString();
        //                        tableString.Append("</td>");
        //                    }
        //                    else
        //                    {
        //                        tableString.Append("<td class='TdFireLink'></td>");
        //                    }
        //                }

        //                tableString.Append("</tr>");
        //            }
        //            tableString.Append("</table>");
        //        }

        //    return tableString.ToString();
        //}

        //private void SetTable()
        //{
        //    HtmlGenericControl control = new HtmlGenericControl();
        //    control.InnerHtml = this.CreateTable();
        //    this.phTable.Controls.Add(control);
        //}
        //private void GetFireLinkStatus()
        //{
        //    if (ddlFireLinkCode.SelectedValue != null)
        //    {
        //        //--added by huangyao 20090108
        //        int FireLinkCode = 0;
        //        int.TryParse(ddlFireLinkCode.SelectedValue.ToString(), out FireLinkCode);

        //        DataTable dt = DAL.SOM.CodeSetup.CDFireLinkStatus.GetFireStatusByID(FireLinkCode);
        //        //---end                

        //        //begin updata, by hzx, on 20090113
        //        //BindListControl(this.rblFireLinkStatus, "FirelinkStatusID", "FireLinkStatus", ODMS.DAL.SOM.CodeSetup.CDFireLinkStatus.GetFireLinkStatus(this.LangCode, this.Version.ToString()), false); --updata bu hzx,on 20090113
        //        BindListControl(this.rblFireLinkStatus, "FireLinkStatusID", "FireLinkStatusCode", DAL.SOM.CodeSetup.CDFireLinkStatus.GetAllFireLinkStatus(this.LangCode), false);
        //        if (DAL.CommonData.GetCharVal("MV_SOM_FireZoneGroupLoopStatusVRT_Visible").ToUpper() == "N" && rblFireLinkStatus.Items.FindByValue("3") != null)
        //        {
        //            rblFireLinkStatus.Items.Remove(rblFireLinkStatus.Items.FindByValue("3"));
        //        }
        //        this.rblFireLinkStatus.SelectedIndex = 0;
        //        //end updata

        //        if (dt.Rows.Count > 0)
        //        {
        //            //---huangyao 20090107: fixed issue leave behind by NHM 
        //            //if (dt.Rows[0]["FirelinkStatusID"]!=null) ///this field not null in DB
        //            //{
        //            ////this.rblFireLinkStatus.Items.FindByValue(dt.Rows[0]["FirelinkStatusID"].ToString()).Selected = true;
        //            //this.FindByValueAndSelect(rblFireLinkStatus, dt.Rows[0]["FirelinkStatusID"].ToString());
        //            //}
        //            this.FindByValueAndSelect(rblFireLinkStatus, dt.Rows[0]["FirelinkStatusID"].ToString());
        //            //-end--huangyao 20090107: fixed issue leave behind by NHM 
        //        }
        //    }
        //}
        //private void SetLanguage()
        //{
        //    this.lblFireLinkStatus.Text = GetLabel("SOM_FireLinkStatus", true);//BJL4 or HK
        //    this.lblFireSystem.Text = this.GetLabel("SOM_FireLink", true);

        //    this.lblFireProtectionGroup.Text = this.GetLabel("SOM_FireGroupStatus");
        //    this.lblStatusReportTime.Text = this.GetLabel("SOM_FrieStatusReportTime", true);
        //    this.lblIsolateFireZone.Text = this.GetLabel("SOM_FireGroupStatus", true);
        //    this.btnRefresh.Text = this.GetLabel("COM_Refresh");
        //    DataTable dtZoneStatus = DAL.SOM.CodeSetup.CDFireGroupStatus.GetFireZoneGroupStatusBylangCode(this.LangCode);
        //    if (dtZoneStatus.Rows.Count > 0)
        //    {
        //        this.lblNormal.Text = dtZoneStatus.Rows[0]["Normal"].ToString();
        //        this.lblIsolate.Text = dtZoneStatus.Rows[0]["Isolated"].ToString();
        //        this.lblRestore.Text = dtZoneStatus.Rows[0]["Restored"].ToString();
        //    }
        //    GetFireLinkStatus();

        //}
        #endregion

        
    }
}
